using System;
using System.Collections.Generic;
using System.Text;

namespace ca.metaobjects.csogateway.Reflection
{
	abstract internal class CsoType
	{
		private bool isCreationComplete = false;
		internal bool IsCreationCompleted
		{
			get { return isCreationComplete; }
		}

		internal void markAsComplete()
		{
			isCreationComplete = true;
		}

		private string namespaceName;
		internal string NamespaceName
		{
			get { return namespaceName; }
			set { namespaceName = value; }
		}

		private string typeName;
		internal string TypeName
		{
			get { return typeName; }
			set { typeName = value; }
		}

		internal string FullTypeName
		{
			get { return String.Format("{0}.{1}", namespaceName, typeName); }
		}

		private List<CsoType> _weakDependencies = new List<CsoType>();
		internal List<CsoType> WeakDependencies 
		{
			get { return _weakDependencies; }
		}

		private List<CsoType> _strongDependencies = new List<CsoType>();
		internal List<CsoType> StrongDependencies
		{
			get { return _strongDependencies; }
		}

		internal void addWeakDependency(CsoType dependencyType)
		{
			bool found = false;
			for (int i = 0; (i < _weakDependencies.Count) && !found; ++i)
			{
				if (_weakDependencies[i].FullTypeName == dependencyType.FullTypeName)
					found = true;
			}

			if (!found)
				_weakDependencies.Add(dependencyType);
		}

		internal void addStrongDependency(CsoType dependencyType)
		{
			bool found = false;
			for (int i = 0; (i < _strongDependencies.Count) && !found; ++i)
			{
				if (_strongDependencies[i].FullTypeName == dependencyType.FullTypeName)
					found = true;
			}

			if (!found)
				_strongDependencies.Add(dependencyType);
		}
	}
}
